package cn.zzuli.securitydemo1.config;

import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @Date: 2020/12/27 13:50
 * @Author: 绯色下午茶
 * @Description:
 */
//@Configuration
public class SecurityConfig1 extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        String encode = passwordEncoder.encode("123");
        System.out.println(encode);
        auth.inMemoryAuthentication().withUser("lucy").password(encode).roles("admin");
    }

    @Bean
    PasswordEncoder getPassword(){
        return new BCryptPasswordEncoder();
    }
}
